import Mock from 'mockjs'
export default {
  getMenu: config => {
    const { username, password } = JSON.parse(config.body)
    // 先判断用户是否存在
    // 判断账号和密码是否对应
    if (username === 'admin' && password === '123456') {
      return {
        code: 20000,
        data: {
          menu: [
            {
              path: '/home',
              name: 'home',
              label: '首页',
              icon: 's-home',
              url: 'Home.vue'
            },
            {
              path: '/user',
              name: 'user',
              label: '用户管理',
              icon: 'user',
              url: 'User.vue'
            },
            {
              path: '/mall',
              name: 'mall',
              label: '商品管理',
              icon: 's-shop',
              url: 'Mall.vue'
            },
            {
              path: '/order',
              name: 'order',
              label: '订单管理',
              icon: 's-order',
              url: 'Order.vue'
            },
            {
              path: '/data',
              name: 'data',
              label: '数据管理',
              icon: 's-data',
              url: 'Data.vue'
            },
            {
              path: '/power',
              name: 'power',
              label: '权限管理',
              icon: 'setting',
              url: 'Power.vue'
            },
            {
              path: '/tool',
              name: 'tool',
              label: '工具管理',
              icon: 's-tools',
              url: 'Tool.vue'
            },
          ],
          token: Mock.Random.guid(),
          message: '获取成功'
        }
      }
    } else if (username === 'test' && password === '123456') {
      return {
        code: 20000,
        data: {
          menu: [
            {
              path: '/home',
              name: 'home',
              label: '首页',
              icon: 's-home',
              url: 'Home.vue'
            },
            {
              path: '/mall',
              name: 'mall',
              label: '商品管理',
              icon: 's-shop',
              url: 'Mall.vue'
            }
          ],
          token: Mock.Random.guid(),
          message: '获取成功'
        }
      }
    } else {
      return {
        code: -999,
        data: {
          message: '密码错误'
        }
      }
    }

  }
}